<?php

namespace app\index\logic;

use think\Model;
use app\index\model\Sign as SignModel;

class Sign extends Model
{
	public static function getInfo()
	{
		$user = SignModel::get(['uid'=>session('uid')]);

		$info = [
			'is_login'=>session('uid')
		];

		if($user){
			if($user->sdate==date("Y-m-d")){
				$info['is_sign'] = true;
				$info['snum'] = $user->snum;
				$info['kiss'] = self::getKiss($user->snum);
				return $info;
			}elseif($user->sdate==date("Y-m-d",strtotime('-1 days'))){
				$info['is_sign'] = false;
				$info['snum'] = $user->snum;
				$info['kiss'] = self::getKiss($user->snum+1);
				return $info;
			}
		}

		$info['is_sign'] = false;
		$info['snum'] = 0;
		$info['kiss'] = 5;

		return $info;
	}

	public static function getKiss($day)
	{
		if($day<=5){
			return 5;
		}elseif($day<=10){
			return 10;
		}elseif($day<=20){
			return 20;
		}else{
			return 30;
		}
	}
}